-> Read, translate to motorola, and fill in the current
-> thing object
Read(wh.dosh,{m}+2,2)
cthing.x:=motoword(m)
Read(wh.dosh,{m}+2,2)
cthing.y:=motoword(m)
Read(wh.dosh,{m}+2,2)
cthing.angle:=motoword(m)
Read(wh.dosh,{m}+2,2)
cthing.type:=motoword(m)
Read(wh.dosh,{m}+2,2)
cthing.options:=motoword(m)
-> Point to next thing
d:=d+10
-> If we're still in the thing lump...
IF(d<dirblock.size)
-> ... allocate another thing object
IF(m:=NewM(SIZEOF thing,MEMF_ANY+MEMF_CLEAR))
-> And make the previous thing object point to the current
-> one, and the current one point to the last one.
cthing.nextthing:=m
cthing.nextthing.prevthing:=cthing
cthing:=m
ELSE
-> Not enough memory, so free any we've already allocated
-> and return failure
freethings(thinglist)
RETURN 0
ENDIF
ENDIF
ENDWHILE
RETURN thinglist
ELSE
RETURN 0
ENDIF
ENDIF
-> Eek! No things!
IF(StrCmp(dirblock.name,'MAP',3)) THEN RETURN 0
IF(StrCmp(dirblock.name,'LINEDEFS')=0) AND (StrCmp(dirblock.name,'SIDEDEFS')=0) AND (StrCmp(dirblock.name,'VERTEXES')=0) AND (StrCmp(dirblock.name,'SEGS')=0) AND (StrCmp(dirblock.name,'SSECTORS')=0) AND (StrCmp(dirblock.name,'NODES')=0) AND (StrCmp(dirblock.name,'SECTORS')=0) AND (StrCmp(dirblock.name,'REJECT')=0) AND (StrCmp(dirblock.name,'BLOCKMAP')=0) THEN RETURN 0
ENDWHILE
ENDPROC 0
-> Scans the WAD dir for a specific lump
EXPORT PROC findentry(entryname,wh:PTR TO wadhandle,dirblock:PTR TO dirblock)
DEF c=0
WHILE(c<wh.numlumps)
readentry(c*16,wh,dirblock)
IF(StrCmp(dirblock.name,entryname)) THEN RETURN -1,c
INC c
ENDWHILE
ENDPROC 0,0
-> Reads a directory entry into a dirblock structure
EXPORT PROC readentry(offset,wh:PTR TO wadhandle,dirblock:PTR TO dirblock)